// 校验手机号
var checkPhone = (rule, value, callback) => {
  const reg = /^((13[0-9])|(14[5,7,9])|(15([0-3]|[5-9]))|(16[5,6])|(17[0-8])|(18[0-9])|(19[1、5、8、9]))\d{8}$/
  // const reg = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/
  if (!reg.test(value)) {
    callback(new Error('请输入正确的手机号'))
  } else {
    callback()
  }
}

// 校验Email
var checkEmail = (rule, value, callback) => {
  const reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/
  if (!reg.test(value)) {
    callback(new Error('请输入正确的邮箱'))
  } else {
    callback()
  }
}

var checkPass = (rule, value, callback) => {
  const reg = /^[a-zA-Z0-9-*/+.~!@#$%^&*()]{6,16}$/
  if (!reg.test(value)) {
    callback(new Error('密码长度6到16位'))
  } else {
    callback()
  }
}
var positiveInteger = (rules, value, callback) => {
  let reg = /^[1-9]\d*$/
  let bool = reg.test(value)
  if (bool) {
    callback()
  } else {
    callback('请输入正整数')
  }
}

module.exports = {
  checkPhone,
  checkPass,
  checkEmail,
  positiveInteger
}
